import { Input, Component, OnInit, OnChanges,DoCheck,AfterContentInit,AfterContentChecked,AfterViewInit,AfterViewChecked,OnDestroy } from '@angular/core';


let logindex:number = 1;

@Component({
  selector: 'app-life',
  templateUrl: './life.component.html',
  styleUrls: ['./life.component.css']
})
export class LifeComponent implements OnInit,OnChanges,DoCheck,AfterContentInit,AfterContentChecked,AfterViewInit,AfterViewChecked,OnDestroy {

  @Input()
  name:string = '';

  //定义函数用来输出调用日志
  logIt(message:string){
    console.log('#'+ (logindex++) +' '+message)
  }

  constructor() {
    this.logIt('name属性的值是'+this.name);
  }

  ngOnInit() {
    this.logIt('ngOnInit');
  }

  ngOnChanges(){
    this.logIt('name属性的值是'+this.name);
  }

  ngDoCheck(){
    this.logIt('ngDoCheck');
  }

  ngAfterContentInit(){
    this.logIt('ngAfterContentInit');
  }

  ngAfterContentChecked(){
    this.logIt('ngAfterContentChecked');
  }

  ngAfterViewInit(){
    this.logIt('ngAfterViewInit');
  }

  ngAfterViewChecked() {
    this.logIt('ngAfterViewChecked');
  }

  ngOnDestroy(){
    this.logIt('ngOnDestroy');
  }
}
